﻿using MediatR;
using SheepStorage.API.Application.Command.YourTableNameCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandler
{
    public class YourTableNameUpdateCommandHandler : IRequestHandler<YourTableNameUpdateCommand, Results<int>>
    {
        private readonly IYourTableNameService _yourTableNameService;
        public YourTableNameUpdateCommandHandler(IYourTableNameService yourTableNameService)
        {
            _yourTableNameService = yourTableNameService;
        }
        public async Task<Results<int>> Handle(YourTableNameUpdateCommand request, CancellationToken cancellationToken)
        {
            var your = new YourTableName()
            {
                 DawningsheepId=request.DawningsheepId,
                OverBit = request.OverBit,
                DawningsheepWeight = request.DawningsheepWeight,
                BuildingManagementId = request.BuildingManagementId,
                DawningsheepReceipts = request.DawningsheepReceipts,
                DawningsheepTime = request.DawningsheepTime,
                DawningsheepType = request.DawningsheepType,
                NumberOfElements =  request.NumbeFelements,
                PurchaseSerialNumber = request.PurchaseSerialNumber,
                ElEarTag = request.ElEarTag,
                SheepFieldId = request.SheepFieldId,
            };
            var result = await _yourTableNameService.UpdateYourTableNames(your);
            return Results<int>.DataResult(result);
        }
    }
}
